package manning.chapterTwo;

import com.opensymphony.xwork2.ActionSupport;

public class Register extends ActionSupport{
	public String execute(){
		
		return "SUCCESS";
	}
	
	//java bean properties
	private String username;
	private String password;
	private String portfolioname;
	
	public String getUsername(){
		return username;
	}
	public void setUsername(String username){
		this.username = username;
	}
	public String getPassword(){
		return password;
	}
	public void setPassword(String password){
		this.password = password;
	}
	public String getPortfolioname(){
		return portfolioname;
	}
	public void setPortfolioname(String portfolioname){
		this.portfolioname = portfolioname;
	}
	
	//validation code
	public void validate(){
		if(getUsername().length()==0){
			addFieldError("username","User Name is required");
		}
		if(getPassword().length()==0){
			addFieldError("password","Password is required");
		}
		if(getPortfolioname().length()==0){
			addFieldError("portfolioname","Portfolio Name is required");
		}
	}
}